﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cinemax.DTO;
using Cinemax.DAO;

namespace Cinemax
{
    public partial class Submit : System.Web.UI.Page
    {

        public SuatChieuDTO sc = new SuatChieuDTO();
        public PhongChieuDTO pc = new PhongChieuDTO();
        public PhimDTO p = new PhimDTO();
        public VeDTO v = new VeDTO();
        public double tongtien = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["sc"] != null && Request.QueryString["pc"] != null)
            {
                int maSuatChieu = int.Parse((string)Request.QueryString["sc"].Trim());
                int maPhongChieu = int.Parse((string)Request.QueryString["pc"].Trim());
                int maVe = int.Parse((string)Request.QueryString["ve"].Trim());
                sc = SuatChieuDAO.getSuatChieuByID(maSuatChieu);
                p = PhimDAO.getPhimByID(sc.MaPhim);
                pc = PhongChieuDAO.GetPhongChieuByID(maPhongChieu);
                v = VeDAO.getVeByID(maVe);
                tongtien = VeDAO.CalcFare(1, 1);
            }
        }

        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            int maTaiKhoan = int.Parse(Session["user_login"].ToString());
            tongtien = VeDAO.CalcFare(1, 1);
            VeDAO.BookTicket(v.MaVe, 1, 3, maTaiKhoan, tongtien);
            Response.Redirect("personalize.aspx");
        }
    }
}